<template>
  <ViewDoc v-if="showType === 'w'" :url="fileUrl"/>
  <ViewPdf v-else-if="showType === 'f'" :url="fileUrl" :height="height"/>
  <MyRouterView v-else :userInfo="userInfo"/>
</template>
<script lang="ts" setup>
import ViewDoc from "@/components/viewDoc/index.vue"
import ViewPdf from "@/components/viewPdf/index.vue"
import MyRouterView from "@/components/MyRouterView/index.vue"
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'


// import 隐私政策 from "../public/static/pdf/CM20240408.pdf";
// const 隐私政策 = import.meta.env.VITE_CAS_URL + import.meta.env.BASE_URL + 'static/pdf/CM20240408.pdf'; // 修改为您的 PDF 文件的路径
const 隐私政策 = import.meta.env.BASE_URL + 'static/pdf/CM20240408.pdf'; // 修改为您的 PDF 文件的路径


const fileId = ref()
const route = useRoute()
const fileUrl = ref("")
const height = ref(0)
const userInfo = ref()

// 文档类型
const officeTypeVal = ref()

// 显示类型
const showType = ref()

// 在组件加载时获取路由参数，并根据参数加载对应的文件内容
onBeforeMount(()=>{

    fileId.value = route.params.id || 1

    if(fileId.value == '隐私政策'){
      fileUrl.value = 隐私政策
      height.value = 48
    }

    if(fileId.value == '隐私政策'){
      fileUrl.value = 隐私政策
      height.value = 48
    }

    if(fileId.value == '隐私政策摘要'){
      fileUrl.value = 隐私政策
      height.value = 0
    }

    if(fileId.value == '服务协议'){
      fileUrl.value = 隐私政策
      height.value = 0
    }

    if(fileId.value == '用户管理规则及公约'){
      fileUrl.value = 隐私政策
      height.value = 0
    }
    if(fileId.value == 'userInfo'){
      alert(JSON.stringify(route.params))
      userInfo.value = route.params
      showType.value = 'u'
    }

    officeTypeVal.value = route.params.officeType || "w"
    showType.value = officeTypeVal.value
    
})
onMounted(() => {})
</script>
